<%@page import="co.gov.medellin.ssti.sub.model.dao.exception.DAOException"%>
<%@page import="co.gov.medellin.ssti.sub.paoyer.administration.model.vo.UserVO"%>
<%@page import="java.util.Collection"%>
<%@page import="co.gov.medellin.ssti.sub.service.ConsultasService"%>
<%@page contentType="text/html;charset=utf-8"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="<%=request.getContextPath() + "/css/bloques.css"%>"
	rel="stylesheet" type="text/css">
<title>Usuarios Administradores</title>
<script type="text/javascript">
function setValues(codigo, usuario) {
    var formaPadre = opener.document.frmCreateProgram;
    formaPadre.admincodigo.value = codigo ;
    formaPadre.Administrador.value = usuario;
    window.close();                 
}
</script>
</head>
<%
	String doAction = request.getParameter("doAction");
	String usuario = request.getParameter("usuario");
	if (usuario == null)
		usuario = "";
%>
<body>
	<br />
	<p align="center" class="titulosenblanco">USUARIOS ADMINISTRADORES</p>
	<form name="frmCreateUser" method="post" action="usuariosadminprog.jsp">
		<input type="hidden" name="doAction" value="execFind">
		<div align="center">
			<table class="tablaGenericaWidth60">
				<tr>
					<td width="25%" class="celdatabla"><strong>Usuario</strong></td>
					<td width="75%"><input type="text" class="form" name="usuario"
						value="<%=usuario%>" maxlength="40" size="40" /></td>
				</tr>
				<tr>
					<td colspan="2" align="center"><input type="submit"
						value="Buscar" onclick="this.form.submit()" /></td>
				</tr>
			</table>
		</div>
		<%
			if (doAction != null) {
		%>
		<%
				ConsultasService consulta = new ConsultasService();
				Collection<UserVO> rs = null;
				try {
		%>
		<%
			rs = consulta.getUsuAdmin(usuario);
					if (rs != null && !rs.isEmpty()) {
		%>
		<div align="center">
			<table class="tablaGenericaWidth60">
				<tr>
					<td width="10%" class="headerTable">CODIGO</td>
					<td width="65%" class="headerTable">NOMBRE</td>
					<td width="15%" class="headerTable">SELECCIONAR</td>
				</tr>
				<%
					for(UserVO vo : rs) {
				%>
				<tr>
					<td class="form"><%=vo.getName()%></td>
					<td class="form"><%=vo.getDescription()%></td>
					<td class="form"><input type="radio" name="seleccionar"
						onclick="setValues('<%=vo.getCode()%>', '<%=vo.getName()%>')" /></td>
				</tr>
				<%
					} 
				%>
			</table>
		</div>
		<%
			} else {
		%>
		<div align="center" class="celdatabla">No se encontraron registros.</div>
		<%
			}
		%>
		<%
			} catch (DAOException e) {
					e.printStackTrace();
				} 
		%>
		<%
			}
		%>
	</form>
</body>
</html>
